Skip to content

Conversation

timgraham
Copy link
Collaborator

fixes #141

Copy link
Collaborator

@aclark4life aclark4life left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! So the base wrapper got a get_database method that checks for queries_logged. Then various schema methods e.g. create_model call get_database which either returns a database connection or returns OperationDebugWrapper. In OperationDebugWrapper you determine whether you are logging migrations as they are executed or showing migrations prior to execution, via self.wrapped = self.collection if use_collection else self.db.database. LGTM, thanks!

@timgraham
Copy link
Collaborator Author

The last sentence isn't correct. OperationCollector is for collecting, while OperationDebugWrapper executes.

self.wrapped = self.collection if use_collection else self.db.database determines whether OperationCollector / OperationDebugWrapper is wrapping a database or a Collection.

@timgraham timgraham merged commit 2bd7459 into mongodb:main Oct 9, 2024
4 checks passed
@timgraham timgraham deleted the sqlmigrate branch October 9, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PYTHON-4802: add support for sqlmigrate

2 participants